package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveBorrow;
import com.hiultra.archive.service.IArchiveBorrowService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 借阅信息数据Controller
 * 
 * @author ls
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/archive/archiveBorrowData")
public class ArchiveBorrowController extends BaseController
{
    @Autowired
    private IArchiveBorrowService archiveBorrowService;

    /**
     * 查询借阅信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveBorrow archiveBorrow)
    {
        startPage();
        List<ArchiveBorrow> list = archiveBorrowService.selectArchiveBorrowList(archiveBorrow);
        return getDataTable(list);
    }

    /**
     * 导出借阅信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:export')")
    @Log(title = "借阅信息数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveBorrow archiveBorrow)
    {
        List<ArchiveBorrow> list = archiveBorrowService.selectArchiveBorrowList(archiveBorrow);
        ExcelUtil<ArchiveBorrow> util = new ExcelUtil<ArchiveBorrow>(ArchiveBorrow.class);
        util.exportExcel(response, list, "借阅信息数据数据");
    }

    /**
     * 获取借阅信息数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveBorrowService.selectArchiveBorrowById(id));
    }

    /**
     * 新增借阅信息数据
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:add')")
    @Log(title = "借阅信息数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveBorrow archiveBorrow)
    {
        return toAjax(archiveBorrowService.insertArchiveBorrow(archiveBorrow));
    }

    /**
     * 修改借阅信息数据
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:edit')")
    @Log(title = "借阅信息数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveBorrow archiveBorrow)
    {
        return toAjax(archiveBorrowService.updateArchiveBorrow(archiveBorrow));
    }

    /**
     * 删除借阅信息数据
     */
    @PreAuthorize("@ss.hasPermi('archive:archiveBorrowData:remove')")
    @Log(title = "借阅信息数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveBorrowService.deleteArchiveBorrowByIds(ids));
    }
}
